package com.zy.yun.base.common;

/**
 * 分页bean
 */

import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PageBean<T>  implements Serializable {

    private List<T> list;				// list result of this page
    private int pageNumber;				// 页码
    private int pageSize;				// 显示行数
    private int totalPage;				// 总页数
    private long totalRow;				// 总行数

    public PageBean(List<T> list, int pageNumber, int pageSize, int totalPage, long totalRow) {
        this.list = list;
        this.pageNumber = pageNumber;
        this.pageSize = pageSize;
        this.totalPage = totalPage;
        this.totalRow = totalRow;
    }

    public PageBean(List<T> list, int pageNumber, int pageSize, PageInfo pageInfo){
        this.list=list;
        this.pageNumber=pageNumber;
        this.pageSize=pageSize;
        this.totalPage=pageInfo.getPages();
        this.totalRow=pageInfo.getTotal();

    }

    public PageBean(List<T> list) {

        PageInfo<T> pageInfo=new PageInfo<>(list);


        this.list = pageInfo.getList();
        this.pageNumber = pageInfo.getPageNum();
        this.pageSize = pageInfo.getPageSize();
        this.totalPage = pageInfo.getPages();
        this.totalRow = pageInfo.getTotal();
    }

}